package com.datastructure.test.sumoftwoinarray;

import java.util.Arrays;

public class SumOfTwoInArray {

    public static void main(String[] args) {

    }

    public int[] findSumOfTargetInArray(int[] arr,int target){
        Arrays.sort(arr);
        int[] result = new int[2];
        boolean isFind = false;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]>target){
                break;
            }
            for(int j = i+1;j< arr.length;j++){
                if(arr[i]+arr[j]==target){
                    result[0]=i;
                    result[1]=j;
                    isFind=true;
                    break;
                }
            }
            if(isFind){
                break;
            }
        }
        return result;
    }

    public boolean isBackString (int data) {
        String s = String.valueOf(data);
        if(s.length()==1){
            return true;
        }
        int left = 0;
        int right = s.length();
        int mid = (left+right)/2;
        for (int i = 0; i < mid; i++) {
            if(s.charAt(i)!=s.charAt(right-i-1)){
                return false;
            }
        }
        return true;
    }
}
